import uuid
import pyaudio
from config_manager import DEFAULT_CONFIG

# 配置信息
ws_connect_config = {
    "base_url": "wss://openspeech.bytedance.com/api/v3/realtime/dialogue",
    "headers": {
        "X-Api-App-ID": "5976318750",
        "X-Api-Access-Key": "lkG4ZV42yYZb91qjIJl4TYMunX1N9mTK",
        "X-Api-Resource-Id": "volc.speech.dialog",  # 固定值
        "X-Api-App-Key": "PlgvMymc7f3tQnJ6",  # 固定值
        "X-Api-Connect-Id": str(uuid.uuid4()),
    }
}

_default_start_session_req = DEFAULT_CONFIG

def get_start_session_req():
    """动态获取start_session_req配置（从ConfigManager）
    
    Returns:
        dict: start_session_req配置字典
    """
    try:
        # 尝试从ConfigManager获取配置
        from config_manager import get_config_manager
        config_manager = get_config_manager()
        return config_manager.get_config()
    except Exception as e:
        # 如果获取失败，使用默认配置
        print(f"从ConfigManager获取配置失败: {e}，使用默认配置")
        import copy
        return copy.deepcopy(_default_start_session_req)

input_audio_config = {
    "chunk": 3200,
    "format": "pcm",
    "channels": 1,
    "sample_rate": 16000,
    "bit_size": pyaudio.paInt16
}

output_audio_config = {
    "chunk": 3200,
    "format": "pcm",
    "channels": 1,
    "sample_rate": 24000,
    "bit_size": pyaudio.paFloat32
}
